<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../react18/react.development.js"></script>
  <script src="../react18/react-dom.development.js"></script>
  <script src="../react18/babel.min.js"></script>
  <script src="../react18/prop-types.js"></script>
</head>

<body>
  <div id="app"></div>
  <script type="text/babel">
   class Parent extends React.Component{
        state ={
          isLove:true,
          count:0
        }
        render(){
          const {isLove,count} =this.state
          return(
            <div>
              <button onClick={this.handle}>点击</button>
              <p>{count+'父'}</p>
              <h1>{isLove?'我爱你':'我恨你'}</h1>
              <hr/>
              <Child a={count} b={isLove}/>
            </div>
          )
        }
        handle=()=>{
          const {isLove,count}=this.state
          this.setState({isLove:false,count:count+1})
        }
    }

   class Child extends React.Component{
    
      render(){
        const {a,b}=this.props
          return(
            <div>
              <h1>{b?'霁立':'🤮'}</h1>
              <h3>{a}</h3>
            </div>
          )
    
    }
    static propTypes ={
        a:PropTypes.number.isRequired,
        b:PropTypes.bool
    }
   }
const root = ReactDOM.createRoot(document.getElementById('app')).render(<Parent/>)




  </script>
</body>

</html>